home *** CD-ROM | disk | FTP | other *** search
/ MacFormat España 15 / macformat_15.iso / C de cerca / Codewarrior Lite / MacOS Support / Headers / ANSI Headers / exception < prev    next >
Text File  |  1995-12-29  |  4KB  |  170 lines

  1. /************************************************************************/
  2. /*    Project...:    Standard C++ Library                                    */
  3. /*    Name......:    exception                                                */
  4. /*    Purpose...:    exception handling                                        */
  5. /*  Copyright.: ©Copyright 1993-95 by metrowerks inc                    */
  6. /************************************************************************/
  7.  
  8. #ifndef _EXCEPTION_
  9. #define _EXCEPTION_
  10.  
  11. ////// Plauger Exceptions Start //////
  12. #include <defines>
  13.  
  14. #if __MWERKS__
  15. #pragma options align=mac68k
  16.  
  17. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  18. #pragma import on
  19. #endif
  20. #endif
  21.  
  22.         // class xmsg
  23. class xmsg {
  24. public:
  25.     typedef void(*raise_handler)(xmsg&);
  26.     static raise_handler set_raise_handler(raise_handler);
  27.     xmsg(const char * = 0, const char * = 0, const char * = 0);
  28.     xmsg(const xmsg&);
  29.     xmsg& operator=(const xmsg&);
  30.     virtual ~xmsg();
  31.     void raise();
  32.     const char *what() const;
  33.     const char *where() const;
  34.     const char *why() const;
  35.     static void _Throw(xmsg *);
  36. protected:
  37.     virtual void do_raise();
  38.     xmsg(const char *, const char *, const char *, _Bool);
  39. private:
  40.     void _Tidy();
  41.     static raise_handler _Handler;
  42.     const char *_What, *_Where, *_Why;
  43.     _Bool _Alloced;
  44.     };
  45.         // class xlogic
  46. class xlogic : public xmsg {
  47. public:
  48.     xlogic(const char * = 0, const char * = 0, const char * = 0);
  49.     virtual ~xlogic();
  50. protected:
  51.     virtual void do_raise();
  52.     };
  53.         // class xruntime
  54. class xruntime : public xmsg {
  55. public:
  56.     xruntime(const char * = 0, const char * = 0,
  57.         const char * = 0);
  58.     virtual ~xruntime();
  59. protected:
  60.     xruntime(const char *, const char *, const char *, _Bool);
  61.     virtual void do_raise();
  62.     };
  63.         // class badcast
  64. class badcast : public xlogic {
  65. public:
  66.     badcast(const char * = 0, const char * = 0, const char * = 0);
  67.     virtual ~badcast();
  68. protected:
  69.     virtual void do_raise();
  70.     };
  71.         // class invalidargument
  72. class invalidargument : public xlogic {
  73. public:
  74.     invalidargument(const char * = 0, const char * = 0,
  75.         const char * = 0);
  76.     virtual ~invalidargument();
  77. protected:
  78.     virtual void do_raise();
  79.     };
  80.         // class lengtherror
  81. class lengtherror : public xlogic {
  82. public:
  83.     lengtherror(const char * = 0, const char * = 0,
  84.         const char * = 0);
  85.     virtual ~lengtherror();
  86. protected:
  87.     virtual void do_raise();
  88.     };
  89.         // class outofrange
  90. class outofrange : public xlogic {
  91. public:
  92.     outofrange(const char * = 0, const char * = 0,
  93.         const char * = 0);
  94.     virtual ~outofrange();
  95. protected:
  96.     virtual void do_raise();
  97.     };
  98.         // class overflow
  99. class overflow : public xruntime {
  100. public:
  101.     overflow(const char * = 0, const char * = 0,
  102.         const char * = 0);
  103.     virtual ~overflow();
  104. protected:
  105.     virtual void do_raise();
  106.     };
  107.         // class xdomain
  108. class xdomain : public xlogic {
  109. public:
  110.     xdomain(const char * = 0, const char * = 0, const char * = 0);
  111.     virtual ~xdomain();
  112. protected:
  113.     virtual void do_raise();
  114.     };
  115.         // class xrange
  116. class xrange : public xruntime {
  117. public:
  118.     xrange(const char * = 0, const char * = 0, const char * = 0);
  119.     virtual ~xrange();
  120. protected:
  121.     virtual void do_raise();
  122.     };
  123. #if __MWERKS__
  124. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  125. #pragma import reset
  126. #endif
  127.  
  128. #pragma options align=reset
  129. #endif
  130. ////// Plauger Exceptions End //////
  131.  
  132. #ifndef _STDEXCEPT_
  133. #include <stdexcept>
  134. #endif
  135.  
  136. #if __MWERKS__
  137. #pragma options align=mac68k
  138.  
  139. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  140. #pragma import on
  141. #endif
  142. #endif
  143.  
  144. class bad_exception : public exception {
  145. public:
  146.     bad_exception() throw() {}
  147.     bad_exception(const bad_exception&) throw() {}
  148.     bad_exception& operator=(const bad_exception&) throw() { return *this; }
  149. //    virtual ~bad_exception() throw();
  150.     virtual const char* what() const /*throw()*/;
  151. };
  152.  
  153. typedef void (*terminate_handler)();
  154. terminate_handler set_terminate(terminate_handler);
  155. void terminate();
  156.  
  157. typedef void (*unexpected_handler)();
  158. unexpected_handler set_unexpected(unexpected_handler);
  159. void unexpected();
  160.  
  161. #if __MWERKS__
  162. #if __CFM68K__ && __USING_IMPORTED_ANSI__
  163. #pragma import reset
  164. #endif
  165.  
  166. #pragma options align=reset
  167. #endif
  168.  
  169. #endif
  170.